<?php
/**
 * Notes:
 * User: wudg <544038230@qq.com>
 * Date: 2025/3/31 14:05
 */

namespace App\Components\Logs\User;


use App\Components\Logs\LogAgent;
use App\Dao\Users\UsersVisLogDao;
use App\Model\Users\UsersVisLog;
use Hyperf\AsyncQueue\Job;

class UserLoginLog extends Job
{
    /**
     * 最大尝试次数
     * @var int
     */
    protected int $maxAttempts = 1;


    /**
     * @var array 登录日志数据
     */
    protected $logData;



    public function __construct(array $data)
    {
        $this->logData = $data;
    }
    public function handle()
    {
        $sysVisLog = new UsersVisLog();
        (new UsersVisLogDao())->add($sysVisLog,$this->logData);
        LogAgent::getInstance('event','userLogin')->info("用户{$this->logData['name']} 成功登录系统");

    }
}